<template>
  <div>{{this.$route.params.title}}
       {{this.$route.params.price}}
        <button @click="addcara">添加购物车</button>
  </div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
  name: 'showpro',
  data() {
    return {pro: this.$route.params}
  },
  created() {

  },
  methods: {
    ...mapActions('cart', ['addcar']),
    addcara() {
      this.addcar(this.pro)
      this.$router.push({name: 'cart'})
    }
  }
}
</script>

